#pragma once

#include "WidgetAttribute.h"
#include "Containers/ScriptDelegateImplement.h"

class CType;

//reflectable widget attribute
//this class instance can force convert to  TWeakObjectPtr<T>
class WHENGINE_API CReflectbleWidgetAttribute
{
public:

    CReflectbleWidgetAttribute() = default;

    CReflectbleWidgetAttribute(const CReflectbleWidgetAttribute& Other);

    ~CReflectbleWidgetAttribute()= default;

    //directly set a value to this attribute
    void SetValue(CType* InDataType, const void* InValue);

    //set a function to this attribute
    //function prototype is T()
    void SetFunction(TSharedObjectPtr<RObject> InObject, CFunction* InFunction);

    void SetDelegate(const SScriptDelegateBase& InDelegate);

    //get value of this attribute
    void* GetValue(CType* InDataType) const;

    uint64_t GetHashCode() const;

    bool operator== (const CReflectbleWidgetAttribute& Other) const
    {
        return ValueGetter== Other.ValueGetter;
    }

    void Clear()
    {
        ValueGetter.reset();
    }
protected:
    std::shared_ptr<TWidgetAttributeValueGetterBase> ValueGetter;
    

};